package com.hrp.controller;

import com.hrp.domain.Combox;
import com.hrp.domain.ResponseData;
import com.hrp.domain.Tree;
import com.hrp.domain.User;
import com.hrp.service.CommonService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/8/10 0010.
 */
@RestController
@RequestMapping("common")
public class CommonController {

    @Autowired
    private CommonService commonService;

    @RequestMapping("/getKslbList")
    public List<Combox> getKslbList(){
        return commonService.getKslb();
    }

    @RequestMapping("/getJxksTree")
    public List<Tree> getJxksTree(){
        return commonService.getJxksTree();
    }

    @RequestMapping("/getKhzqList")
    public List<Combox> getKhzqList(){
        return commonService.getKhzqList();
    }

    @RequestMapping("/getLcjj")
    public List<Map<String,Object>> getLcjj(Integer zqid){
        return commonService.getLcjj(zqid);
    }

    @RequestMapping("/getDicList")
    public List<Combox> getDicList(Integer id,String lbdm){
        return commonService.getDicList(id,lbdm);
    }


    @RequestMapping("/commonAdd")
    public ResponseData commonAdd(HttpServletRequest request){
            Map<String,String[]> paraMmap = request.getParameterMap();
            return commonService.commomAdd(paraMmap);
    }


    @RequestMapping("/commonGetListByPage")
    public Map<String, Object> commonGetListByPage(HttpServletRequest request){
        Map<String,String[]> paraMmap = request.getParameterMap();
        return commonService.commonGetListByPage(paraMmap);
    }


    @RequestMapping("/getUimssVarietiesDropList")
    public List<Combox> getUimssVarietiesDropList(Integer id){
        User acount = (User) SecurityUtils.getSubject().getPrincipal();
        return commonService.getUimssVarietiesDropList(id,acount.getUsername());
    }

    @RequestMapping("/getUimssSupplierDropList")
    public List<Combox> getUimssSupplierDropList(Integer id){
        return commonService.getUimssSupplierDropList(id);
    }

    @RequestMapping("/getUimssReceiverDropList")
    public List<Combox> getUimssReceiverDropList(Integer id){
        return commonService.getUimssReceiverDropList(id);
    }


    @RequestMapping("/getUimssVarietiesTree")
    public List<Tree> getUimssVarietiesTree(String searchValue){
        User acount = (User) SecurityUtils.getSubject().getPrincipal();
        return commonService.getUimssVarietiesTree(searchValue,acount.getUsername());
    }

    @RequestMapping("/getUimssSupplierTree")
    public List<Tree> getUimssSupplierTree(String searchValue){
        return commonService.getUimssSupplierTree(searchValue);
    }

    @RequestMapping("/getUimssReceiverTree")
    public List<Tree> getUimssReceiverTree(String searchValue){
        return commonService.getUimssReceiverTree(searchValue);
    }

    @RequestMapping("/getLoginUser")
    public ResponseData getLoginUser(){
        User acount = (User) SecurityUtils.getSubject().getPrincipal();
        return ResponseData.build(200,"获取用户成功",acount);
    }



}
